package com.ftg.learn.chapter18;


import com.ftg.learn.chapter17.DemoTest;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * 测试一个这个功能
 *
 * @author kangjx
 * @version 1.0
 * @date 2023/3/28 上午9:01
 */
public class JavaBaseDemo {

    public static void main(String[] args) {



        AnnotationConfigApplicationContext beanFactory = new AnnotationConfigApplicationContext();
        beanFactory.register(JavaBaseConfiguration.class);
        //要求是包下面的所有类，但是做为组件的类要求有注解 @Component
        beanFactory.scan("com.ftg.learn.chapter18");
        beanFactory.registerBean("demotest", DemoTest.class);
        beanFactory.registerBean("demotest1", DemoTest.class);
        beanFactory.refresh();


        Panda bean = (Panda) beanFactory.getBean("initPanda");
        System.out.println(bean.getName());

        DemoTest bean1 = (DemoTest) beanFactory.getBean("demotest");
        System.out.println(bean1.getName());
    }

}
